/*
 * @Author: gaoh
 * @Date: 2024-05-07 09:54:11
 * @LastEditTime: 2024-05-07 13:17:48
 */
#define _GNU_SOURCE

#include <stdio.h>
#include <string.h>


void *memmem(const void *haystack, size_t haystacklen, const void *needle, size_t needlelen);

int main() {
    const char *haystack = "Hello, world!";
    const char *needle = "world";
    
    // 在 haystack 中查找 needle
    void *result = memmem(haystack, strlen(haystack), needle, strlen(needle));
    
    if (result != NULL) {
        printf("Found needle at position: %ld\n", (char *)result - haystack);
    } else {
        printf("Needle not found.\n");
    }
    
    return 0;
}